package cn.com.yiqi.wsc.common;

/**
 * @author 何刚
 * @ClassName: ${class}
 * @Description: TODO
 * @date 2016/12/6
 */
public class ResultUtil {

    public static Result success(Result result) {

        result.setStatus(ResultEnum.SUCCESS.getValue());
        return result;

    }

    public static Result fail(Result result, String msg) {

        result.setStatus(ResultEnum.OTHER.getValue());
        result.setErrMsg(msg);

        return result;

    }

    /**
     * 参数错误
     *
     * @param result
     * @param msg
     * @return
     */
    public static Result paramError(Result result, String msg) {

        result.setStatus(ResultStatusEnum.参数错误.getCode());
        result.setErrMsg(msg);

        return result;
    }


    public static Boolean isSuccess(Result result) {
        return result.getStatus() == ResultEnum.SUCCESS.getValue() || ResultStatusEnum.操作成功.getCode().equals(result.getStatus());
    }
}
